<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('增加部门岗位关联')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-dept-edit">
        <input id="deptId" name="deptId" type="hidden" th:value="${deptId}"/>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-xs-2 control-label">分配岗位：</label>
                    <div class="col-xs-10">
                        <label th:each="post:${posts}" class="check-box">
                            <input name="post" type="checkbox" th:value="${post.id}" th:text="${post.postName}"
                                   th:checked="${post.checked}" th:disabled="${post.use == 'false'}">
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">

    function submitHandler() {
        if ($.validate.form()) {
            edit();
        }
    }

    function edit() {
        const deptId = $("input[name='deptId']").val();
        const postIds = $.form.selectCheckeds("post")
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "system/dept/updatePostLink",
            data: {
                "deptId": deptId,
                "postIds": postIds
            },
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>
